﻿using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using AvaloniaApplication1.ViewModels.CardViewModel;

namespace AvaloniaApplication1.ViewModels;

public class HomePageViewModel : INotifyPropertyChanged
{
    private string _message = "欢迎使用Avalonia这是首页";
    public TmphumViewModel TmphumVm { get; }
    public DataGridViewModel DataGridVm { get; }

    public string Message
    {
        get => _message;
        set => SetField(ref _message, value);
    }

    public event PropertyChangedEventHandler? PropertyChanged;

    protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null)
    {
        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
    }

    private bool SetField<T>(ref T field, T value, [CallerMemberName] string? propertyName = null)
    {
        if (EqualityComparer<T>.Default.Equals(field, value)) return false;
        field = value;
        OnPropertyChanged(propertyName);
        return true;
    }
    public HomePageViewModel(TmphumViewModel tmphumViewModel, DataGridViewModel dataGridViewModel)
    { 
        TmphumVm = tmphumViewModel;
        DataGridVm=dataGridViewModel;
    }
}